#ifndef CAMERA_H
#define CAMERA_H

#include <math.h>
#include "UniversalIncludes.h"
#include "SceneObject.h"
#include "Engine.h"
#include <iostream>

static const double PI = 3.141593;
static const double PID2 = 1.570796; // = PI / 2

class Camera : public SceneObject
{
    // Fields
    protected:
        //GLfloat eye[3]; Eye coordinates are x,y,z defined in sceneObject
        GLfloat center[3];
        GLfloat up[3];

    // Methods
    public:
        Camera();
        virtual ~Camera(){};
        void setup();
        void setEye(GLfloat ex, GLfloat ey, GLfloat ez);
        void setCenter(GLfloat cx, GLfloat cy, GLfloat cz);
        void setUp(GLfloat ux, GLfloat uy, GLfloat uz);
};

class FreeViewCamera : public Camera
{
    // Fields
    private:
        int move;
        int strafe;
        bool warpedEvent;       // Ignore next event (created by mouse warping)
    protected:
        GLfloat lineSight[3];   // Camera's line of sight (LOS)
		GLfloat yAngle, xAngle;

    // Methods
    public:
        FreeViewCamera();
        virtual ~FreeViewCamera(){};
        void update(Uint32* deltaTime);
        void handleEvents(SDL_Event* event);
};

class SceneRotateCamera : public Camera
{
    // Fields
    private:
        bool warpedEvent;
    protected:
        GLfloat rCylindrical;
        GLfloat phi;                // Angle away from the positive Z axis, 0 to 90 degrees
        GLfloat theta;              // Angle in the XY plane, 0 to 360 degrees
        GLfloat distance;           // Distance from camera to the center
        GLfloat yAngle, xAngle;

    // Methods
    public:
        SceneRotateCamera();
        virtual ~SceneRotateCamera(){};
        void update(Uint32* deltaTime);
        void handleEvents(SDL_Event* event);
        void setPhi(GLfloat newPhi);
        void setTheta(GLfloat newTheta);
        void setDistance(GLfloat newDistance);      // Set distance from camera
        void addDistance(GLfloat dist);             // Add to current camera distance
};

#endif
